package com.xinzhi.controller;


import com.xinzhi.anno.CheckRole;
import com.xinzhi.domain.User;
import com.xinzhi.domain.dto.UserDto;
import com.xinzhi.handler.LoginInterceptor;
import com.xinzhi.utils.Result;
import com.xinzhi.utils.UserThreadLocal;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/text")
@ResponseBody
public class dddd {
    @RequestMapping
    public Result result(){
    User user = UserThreadLocal.get();
        System.out.println(user);
      return  Result.ok(null);
    }


    @CheckRole(role = {"tz", "admin"})
    @GetMapping("/user")
    public Result<Object> test(){
        UserDto userDto = LoginInterceptor.userLocal.get();
        return Result.ok(userDto);
    }

    @CheckRole(role = {"user"})
    @GetMapping("/user1")
    public Result<Object> test1(){
        UserDto userDto = LoginInterceptor.userLocal.get();
        return Result.ok(userDto);
    }
}
